import { requestClient } from '../request'
import { useAppConfig } from '@vben/hooks'
const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD)

// 私有消息
export default class UserFollowApi {
    static get inst() {
        return UserFollowApi._inst || (UserFollowApi._inst = new UserFollowApi())
    }
    private static _inst: UserFollowApi
    /**
     * UserFollowApi分页
     * @param params
     */
    getPageList(params: any) {
        return requestClient.get(
            '/stockPrivateMessage/index',
            {
                params
            }
        )
    }
    // Post上传文件
    upload(data: { file: File }) {
        // 使用requestClient的put方法，上传文件到/orders/importOrders接口，data为上传的文件，headers为请求头，'Content-Type'为multipart/form-data
        return requestClient.post(
            `/stockPrivateMessage/userImport`,
            { file: data.file },
            {
                headers: {
                    'Content-Type': 'multipart/form-data'
                }
            }
        )
    }
    // Post上传文件
    upload2(data: { file: File }) {
        // 使用requestClient的put方法，上传文件到/orders/importOrders接口，data为上传的文件，headers为请求头，'Content-Type'为multipart/form-data
        return requestClient.post(
            `/stockPrivateMessageLog/import`,
            { file: data.file },
            {
                headers: {
                    'Content-Type': 'multipart/form-data'
                }
            }
        )
    }
    // 开始工作
    start(params: any) {
        return requestClient.post('/stockPrivateMessage/startWork', params)
    }

    // 工作详情进度
    readWorkProgress(id: number) {
        return requestClient.get(`/stockPrivateMessage/readWorkProgress?workId=${id}`)
    }
    // 工作结束
    endWork(id: number) {
        return requestClient.get(`/stockPrivateMessage/endWork?workId=${id}`)
    }
    // 导出
    export(type: number) {
        let url = apiURL + `/stockPrivateMessage/export?type=${type}`
        window.open(url)
    }
    // 清空
    clear(batchNumber: string) {
        return requestClient.get(`/stockPrivateMessage/clear?batchNumber=${batchNumber}`)
    }
}
